<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/2
 * Time: 17:13
 */
include "config.php";
session_start();
if($_SERVER["REQUEST_METHOD"]=="POST"){
    if(!empty($_POST["uname"])&&!empty($_POST["upwd"])){
        $name=$_POST["uname"];
        $pwd=$_POST["upwd"];
        print_r($name,$pwd);
        $readySQL="SELECT * FROM fashionshopping.userinfo WHERE u_name=? AND u_pwd=?";
        $backMSG=$conn->prepare($readySQL);
        $backMSG->bind_param("ss",$name,$pwd);
        $backMSG->execute();
        $result=$backMSG->get_result();
        if($result->num_rows>=1){
            $resList=Array("status"=>1,"msg"=>"恭喜，登录成功");
            $rowData = $result->fetch_array();
            $loginArray=Array();
            $loginArray["uname"]=$rowData["u_name"];
            $loginArray["utel"]=$rowData["u_tel"];
            $resList["data"]=$loginArray;
            $_SESSION["ifLogin"]=$loginArray;
            print_r(json_encode($resList));
        }else{
            print_r(json_encode(Array("status"=>0,"msg"=>"用户名或密码错误")));
        }
    }else{
        print_r(json_encode(Array("status"=>0,"msg"=>"参数格式错误")));
    }
}else{
    print_r(json_encode(Array("status"=>0,"msg"=>"请使用POST请求")));
}